# Contributor: Oleg Titov <oleg.titov@gmail.com>
# Maintainer: Oleg Titov <oleg.titov@gmail.com>
pkgname=cargo-c
pkgver=0.9.11
pkgrel=0
pkgdesc="cargo subcommand to build and install C-ABI compatibile dynamic and static libraries"
url="https://github.com/lu-zero/cargo-c"
arch="all !s390x !riscv64" # no cargo for these archies
license="MIT"
makedepends="cargo openssl-dev"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/lu-zero/cargo-c/archive/v$pkgver.tar.gz
	$pkgname-$pkgver-Cargo.lock::https://github.com/lu-zero/cargo-c/releases/download/v$pkgver/Cargo.lock"

prepare() {
	default_prepare

	cp "$srcdir"/$pkgname-$pkgver-Cargo.lock Cargo.lock
	cargo fetch --locked
}

build() {
	cargo build --release --frozen
}

check() {
	cargo test --release --frozen
}

package() {
	cargo install --locked --root "$pkgdir/usr" --path .

	install -Dm 644 -t "$pkgdir/usr/share/doc/cargo-c" README.md

	rm "$pkgdir"/usr/.crates.toml
	rm "$pkgdir"/usr/.crates2.json
}

sha512sums="
ab815d6a5a6d37ff7cf57dfb50732e709fabc7a7b8a1135ecfb4cf0b036782edb378315cb7f9f2a632e2893215d8c046e18fe62f823bf7bc02c361afd020551c  cargo-c-0.9.11.tar.gz
481b69f683e261b2a6d852b7df904489f88389cc1f9080346397da13d3737fd8b3eabe3ad2dffa3ace232b1220a06f958f0d72195000ceae17750d38fed470d9  cargo-c-0.9.11-Cargo.lock
"
